package light.head.dao.oa;

import java.util.List;

import light.head.framework.base.BaseDAO;
import light.head.model.ReturnItem;

import org.springframework.stereotype.Service;
/***
 * 物品归还明细
 * @author yy
 *
 */
@Service
public class ReturnItemDAO extends BaseDAO<ReturnItem, Integer>{
	private static final String hql_findByReturnCode = " FROM ReturnItem item WHERE item.rc = ? ORDER BY item.code";
	
	
	
	public List<ReturnItem> findByConCode(Integer cdCode) {
		if (cdCode != null) return find(hql_findByReturnCode, cdCode);
		return null;
	}
	
	
	public List<ReturnItem> findByConCodes(List<Object> cdCodes) {
		if (null == cdCodes || cdCodes.size() == 0) return null;
		
		StringBuffer hql = new StringBuffer(" FROM ReturnItem item WHERE item.rc IN (");
		for (int i = 0; i < cdCodes.size(); i++) {
			hql.append("?,");
		}
		hql.deleteCharAt(hql.length() - 1).append(")");
		return find(hql.toString(), null, null, cdCodes.toArray());
	}
	
	
	
	/**
	 * 根据编号cc 和 商品编号gc 获得商品领用明细
	 */
	public List<ReturnItem> findBygc(Integer gc){
		String hql = " FROM ReturnItem item WHERE item.gc = ?";
		return findI(hql,gc);
	}
}
